<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>定时任务新增</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/lib/layui-v2.5.4/css/layui.css" media="all">
    <link rel="stylesheet" href="/css/public.css" media="all">
    <style>
        .layui-form-item .layui-input-company {
            width: auto;
            padding-right: 10px;
            line-height: 38px;
        }
    </style>
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">
        <div class="layui-form layuimini-form">
            <input hidden="hidden" name="status" value="false">
            <input hidden="hidden" name="clazzPathId">
            <div class="layui-form-item">
                <label class="layui-form-label required">任务名称</label>
                <div class="layui-input-inline">
                    <input type="text" name="jobName" lay-verify="required" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label required">任务表达式</label>
                <div class="layui-input-inline">
                    <input type="text" name="cron" lay-verify="required" class="layui-input">
                </div>
                <label class="layui-form-label">
                    <a href="http://cron.qqe2.com/" target="_blank" style="color: #0000FF;">获取表达式</a>
                </label>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label required">启用状态</label>
                <div class="layui-input-block">
                    <input type="checkbox" name="isStatus" lay-skin="switch" value="false"
                           lay-filter="isStatus" lay-text="已启用|未启用" title="状态">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label required">任务执行方法</label>
                <div class="layui-input-inline">
                    <select lay-verify="required" lay-search="" lay-filter="clazz_path">
                        <option value="">直接选择或搜索选择</option>
                        <option th:each="taskEnum:${TaskEnum}"
                                th:text="${taskEnum.name}" th:value="${taskEnum.id}">layer
                        </option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">简介</label>
                <div class="layui-input-block">
                    <textarea name="note" placeholder="请输入简介"
                              class="layui-textarea"></textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit lay-filter="saveBtn">确认保存</button>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="/lib/layui-v2.5.4/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form', 'element'], function () {
        var $ = layui.jquery,
            form = layui.form,
            element = layui.element;
        //监听提交
        form.on('submit(saveBtn)', function (param) {
            $.ajax({
                url: "/api/admin/setting/task/confirm/add",
                type: "post",
                data: param.field,
                success: function (rst) {
                    parent.layer.msg(rst.msg, {time: 1000}, function () {
                        parent.layer.close(parent.layer.getFrameIndex(window.name));
                        //重新加载父页面
                        parent.location.reload();
                    });
                }
            });
            return false;
        });
        //监听是否锁定
        form.on('switch(isStatus)', function (data) {
            $("[name=status]").val(this.checked);
        });
        //监听下拉框
        form.on('select(clazz_path)', function (data) {
            $("[name=clazzPathId]").val(data.value);
        });
    });
</script>
</body>
</html>